// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC

@use "refactor/common-refactor.scss" as deprecated;

.custom-select {
  --border-color: var(--menu-background-color);
  --bg-color: var(--menu-background-color);
  --icon-color: var(--icon-foreground);
  --text-color: var(--menu-foreground-color);
  @extend .new-scrollbar;
  @include deprecated.bodySmallTypography;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: deprecated.$s-32;
  width: 100%;
  margin: 0;
  padding: deprecated.$s-8;
  border-radius: deprecated.$br-8;
  background-color: var(--bg-color);
  border: deprecated.$s-1 solid var(--border-color);
  color: var(--text-color);
  cursor: pointer;

  &.icon {
    grid-template-columns: auto 1fr auto;
  }

  &:hover {
    --bg-color: var(--menu-background-color-hover);
    --border-color: var(--menu-background-color);
    --icon-color: var(--menu-foreground-color-hover);
  }

  &:focus {
    --bg-color: var(--menu-background-color-focus);
    --border-color: var(--menu-background-focus);
  }
}

.disabled {
  --bg-color: var(--menu-background-color-disabled);
  --border-color: var(--menu-border-color-disabled);
  --icon-color: var(--menu-foreground-color-disabled);
  --text-color: var(--menu-foreground-color-disabled);
  pointer-events: none;
  cursor: default;
}

.dropdown-button {
  @include deprecated.flexCenter;
  margin-inline-end: var(--sp-xxs);
  svg {
    @extend .button-icon-small;
    transform: rotate(90deg);
    stroke: var(--icon-color);
  }
}

.current-icon {
  @include deprecated.flexCenter;
  width: deprecated.$s-24;
  padding-right: deprecated.$s-4;
  svg {
    @extend .button-icon-small;
    stroke: var(--icon-foreground);
  }
}

.custom-select-dropdown {
  @extend .dropdown-wrapper;
  .separator {
    margin: 0;
    height: deprecated.$s-12;
    border-block-start: deprecated.$s-1 solid var(--dropdown-separator-color);
  }
}

.custom-select-dropdown[data-direction="up"] {
  bottom: deprecated.$s-32;
  top: auto;
}

.checked-element {
  @extend .dropdown-element-base;
  .icon {
    @include deprecated.flexCenter;
    height: deprecated.$s-24;
    width: deprecated.$s-24;
    padding-right: deprecated.$s-4;
    svg {
      @extend .button-icon;
      stroke: var(--icon-foreground);
    }
  }

  .label {
    flex-grow: 1;
    width: 100%;
  }

  .check-icon {
    @include deprecated.flexCenter;
    svg {
      @extend .button-icon-small;
      visibility: hidden;
      stroke: var(--icon-foreground);
    }
  }

  &.is-selected {
    color: var(--menu-foreground-color);
    .check-icon svg {
      stroke: var(--menu-foreground-color);
      visibility: visible;
    }
  }
  &.disabled {
    display: none;
  }
}

.current-label {
  @include deprecated.textEllipsis;
}
